﻿///<reference path="../../scripts/jquery-1.4.4.min.js" />
///<reference path="../../scripts/kooboo/kooboo.form.js" />

$(function () {
    //1.support
    $(".changestatus-form").submit(function () {
        var form = $(this);

        form.ajaxPost({
            success: function () {
                form.find("select").attr("disabled", "disabled");
                form.find(".edit-view").toggleClass("hide");
                form.find(".display-view").toggleClass("hide");
            }
        });

        return false;
    });

    $(".edit").click(function (e) {
        e.preventDefault();

        var form = $(this).parent();
        var select = form.find("select");
        select.removeAttr("disabled");
        select.attr("original", select.val());

        form.find(".display-view").toggleClass("hide");
        form.find(".edit-view").toggleClass("hide");

        return false;
    });

    $(".save").click(function (e) {
        e.preventDefault();

        var form = $(this).parent();

        form.submit();

        return false;
    });

    $(".cancel").click(function (e) {
        e.preventDefault();

        var form = $(this).parent();
        var select = form.find("select");
        select.attr("disabled", "disabled");
        select.val(select.attr("original"));

        form.find(".display-view").toggleClass("hide");
        form.find(".edit-view").toggleClass("hide");

        return false;
    });

    //2.reply
    $("#reply_form").submit(function () {

        $(this).ajaxPost();
        return false;
    });


})